﻿// =================================================================== 
// 模块说明
//====================================================================
// 创建时间：2018-12-25 10:32:38
// 负责人：lvsc
// ===================================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq.Expressions;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using OF.Utility;
using OF.Component.Model;
using OF.Component.IDAL;
using System.Text;
namespace OF.Component.DAL
{
	
	/// <summary>
	///业务配置 数据访问层
	/// </summary>	
	internal partial class BizTypeCityRela
	{		
    
        /// <summary>
    	/// 根据断言条件获取单个业务配置
    	/// </summary>
        public BizTypeCityRelaInfo QuerySingle(Expression<Func<BizTypeCityRelaInfo, bool>> predicate)
	    {
            return SQLServerProvider.CreateObject(ConnectionStringKey, predicate);
        }
        
        /// <summary>
    	/// 根据断言条件获获取业务配置列表
    	/// </summary>
	    public IList<BizTypeCityRelaInfo> QueryList(Expression<Func<BizTypeCityRelaInfo, bool>> predicate)
	    {
	        return SQLServerProvider.CreateList(ConnectionStringKey, predicate);
	    }


        /// <summary>
        /// 批量取消业务配置
        /// </summary>
        /// <param name="bizTypeIds"></param>
        /// <param name="cityId"></param>
        /// <returns></returns>
        public bool BatchCancelCfg(List<int> bizTypeIds, int cityId)
        {
            if (bizTypeIds.Count == 0)
            {
                return false;
            }
            string ids = string.Join(",", bizTypeIds.ToArray());
            string strSql = "update BizTypeCityRela set status=0 WHERE CityID=" + cityId + " AND IsActive=1 AND BizTypeID in(" + ids + ") ";
            Database db = DatabaseFactory.CreateDatabase(this.ConnectionStringKey);
            DbCommand dbc = db.GetSqlStringCommand(strSql.ToString());
            return db.ExecuteNonQuery(dbc) > 0;
        }
    }
	
}